package com.kh.pajx.sop.view.action;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.kh.pajx.sop.base.ModelDrivenBaseAction;
import com.kh.pajx.sop.base.SOPConfig;
import com.kh.pajx.sop.domain.HsSchoolInfo;
import com.kh.pajx.sop.domain.SOPCurrentUser;
import com.kh.pajx.sop.domain.StockDeviceDic;
import com.kh.pajx.sop.domain.SysDictionary;
import com.kh.pajx.sop.domain.stock.StockDev;
import com.kh.pajx.sop.domain.stock.StockDevIn;
import com.kh.pajx.sop.domain.stock.StockDevInDetail;
import com.kh.pajx.sop.domain.stock.StockDevOut;
import com.kh.pajx.sop.domain.stock.StockDevOutDetail;
import com.kh.pajx.sop.domain.stock.Supplier;
import com.kh.pajx.sop.util.common.DwzAjaxResult;
import com.kh.pajx.sop.util.common.FormatDate;
import com.kh.pajx.sop.util.excel.ExportExcel;
import com.kh.pajx.sop.util.page.QueryHelper;
import com.kh.pajx.sop.util.sop.PropertyValidate;
import com.opensymphony.xwork2.ActionContext;
/**
 * 库存设备Action
 * @author zhangke
 *
 */
@Controller
@Scope("prototype")
public class StockDevAction extends ModelDrivenBaseAction<StockDeviceDic>{

	private StockDeviceDic devDic;
	private List<StockDeviceDic> dicList;
	private List<String> dataList;
	private StockDevIn stockDevin;
	private String message;
	private StockDevOut stockDevOut;
	
	private List<StockDev> devList;
	
	private String fileName;
    private InputStream excelFile;
    
    private String outCheck;//出库审核状态
    private String inCheck;//入库审核状态
    private String inType;//入库类型
    private String outType;//出库类型
    private String startDate;
    private String endDate;
    private String check_startDate;
    private String check_endDate;
	
	public String stockDevAllList(){
		List<Supplier> supList=supplierService.findAll();
		ActionContext.getContext().put("supList", supList);
		QueryHelper query = new QueryHelper(StockDev.class, "ns");
		query.addCondition(StringUtils.isNotEmpty(StringUtils.trim(model.getDevName())),"ns.devName like ?", "%"+StringUtils.trim(model.getDevName())+"%");
		query.addOrderProperty("ns.uuid", true);
		query.preparePageBean(devService, pageNum, numPerPage);
		return "devAllList";
	}
	
	
	public String listStockDev(){
			QueryHelper query = new QueryHelper(StockDeviceDic.class, "ds");
			query.addCondition(StringUtils.isNotEmpty(StringUtils.trim(model.getDevName())),"ds.devName like ?", "%"+StringUtils.trim(model.getDevName())+"%");
			query.addCondition(StringUtils.isNotEmpty(StringUtils.trim(model.getSpell())),"ds.spell like ?", "%"+StringUtils.trim(model.getSpell())+"%");
			query.addOrderProperty("ds.uuid", true);
			query.preparePageBean(stockService, pageNum, numPerPage);
	return "devList";
	}
	
	
	public String addDicUI(){
		List<Supplier> supplierList=supplierService.findAll();
		ActionContext.getContext().put("supplierList",supplierList);
		return "saveUI";
	}
	public void addDic(){
		DwzAjaxResult dwz = new DwzAjaxResult();
		try {
			model.setDevName(StringUtils.trim(model.getDevName()));
			model.setDevUnit(StringUtils.trim(model.getDevUnit()));
			model.setDescribe(StringUtils.trim(model.getDescribe()));
			model.setDevVer(StringUtils.trim(model.getDevVer()));
			model.setSpell(StringUtils.trim(model.getSpell()));
			model.setDevSupplierId(StringUtils.trim(model.getDevSupplierId()));
			String supplierName=supplierService.getById(model.getDevSupplierId()).getSupplierName();
			model.setDevSupplierName(supplierName);
			model.setIbStop("1");
			stockService.save(model);
			dwz.setMessage("保存成功！");
			dwz.setCallbackType("closeCurrent");
			dwz.setNavTabId("stock_listStockDev");
			dwz.setStatusCode("200");
			DwzAjaxResult.josnMessage(dwz);
		} catch (Exception e) {
			e.printStackTrace();
			dwz.setMessage("保存失败！<br>错误信息：" + e.getMessage());
			dwz.setStatusCode("300");
			DwzAjaxResult.josnMessage(dwz);
		}
	}
	public String editDicUI(){
		StockDeviceDic devDic=stockService.getById(model.getUuid());
		ActionContext.getContext().getValueStack().push(devDic);
		return "editUi";
	}
	
	public void editDic(){
		DwzAjaxResult dwz = new DwzAjaxResult();
		try {
			StockDeviceDic devDic=stockService.getById(model.getUuid());
			
			devDic.setDevName(model.getDevName());
			devDic.setDevUnit(model.getDevUnit());
			devDic.setDevVer(model.getDevVer());
			devDic.setDescribe(model.getDescribe());
			devDic.setSpell(model.getSpell());
			devDic.setIbStop("1");
			stockService.update(devDic);
			dwz.setMessage("修改成功!");
			dwz.setNavTabId("stock_listStockDev");
			dwz.setStatusCode("200");
			DwzAjaxResult.josnMessage(dwz);
		} catch (Exception e) {
			e.printStackTrace();
			dwz.setMessage("保存失败！<br>错误信息：" + e.getMessage());
			dwz.setStatusCode("300");
			DwzAjaxResult.josnMessage(dwz);
		}
	}
	
	public void deleteDic(){
		DwzAjaxResult dwz = new DwzAjaxResult();
		try {
			stockService.delete(model.getUuid());
			dwz.setMessage("删除成功!");
			dwz.setNavTabId("stock_listStockDev");
			dwz.setStatusCode("200");
			DwzAjaxResult.josnMessage(dwz);
		} catch (Exception e) {
			e.printStackTrace();
			dwz.setMessage("删除失败！<br>错误信息：" + e.getMessage());
			dwz.setStatusCode("300");
			DwzAjaxResult.josnMessage(dwz);
		}
		
		
	}
	
	public String addStockInUI(){
		return "stockInUI";
	}
	public String stockDicTabUi(){
		//dicList=stockService.findAll();
		QueryHelper query = new QueryHelper(StockDeviceDic.class, "zg");
		query.addOrderProperty("zg.uuid", true);
		query.preparePageBean(stockService, pageNum, numPerPage);
		return "stock_dic_tab";
		
	}
	
	//来源查找带回
	public String stockGysTabUi(){
		//dicList=stockService.findAll();
		QueryHelper query = new QueryHelper(SysDictionary.class, "dic");
		query.addCondition("dic.dicTypeCode=?", SOPConfig.DIC_CODE_SUPPLIER);
		query.addOrderProperty("dic.dicCode", true);
		query.preparePageBean(sysDictionaryService, pageNum, numPerPage);
		return "stock_gys_tab";
		
	}
	
	//入库登记
	public void StockDevIn(){
		List<StockDevInDetail> detailList=new ArrayList<StockDevInDetail>();
		for (String s : dataList) {
			StockDevInDetail inDetail=new StockDevInDetail();
			String[] str = s.split(",");
			inDetail.setDevUuid(str[1]);
			inDetail.setInNum(Integer.parseInt(str[0]));
			if(str.length>=3){
				inDetail.setDevBackSclId(schoolService.findByName(str[2]).getSclId());
			}
			detailList.add(inDetail);
		}
		DwzAjaxResult dwz = new DwzAjaxResult();
		try {
			stockService.addStockDevin(stockDevin, detailList);
			dwz.setMessage("入库登记成功!");
			dwz.setCallbackType("closeCurrent");
			dwz.setNavTabId("stock_addStockInUI");
			dwz.setStatusCode("200");
			DwzAjaxResult.josnMessage(dwz);
			message="1";
		} catch (Exception e) {
			e.printStackTrace();
			dwz.setMessage("入库登记失败！<br>错误信息：" + e.getMessage());
			dwz.setStatusCode("300");
			DwzAjaxResult.josnMessage(dwz);
		}
	}
	//入库登记审核列表
	public String StockDevInList(){
		try {
			String startDate_in=null;
			String endDate_in=null;
			String startDate_check=null;
			String endDate_check=null;
			if(startDate!=null){
				startDate_in=startDate.replace("-", "").replace(":", "").replace(" ", "");
			}
			if(endDate!=null){
				endDate_in=endDate.replace("-", "").replace(":", "").replace(" ", "");
			}
			if(check_startDate!=null){
				startDate_check=check_startDate.replace("-", "").replace(":", "").replace(" ", "");
			}
			if(check_endDate!=null){
				endDate_check=check_endDate.replace("-", "").replace(":", "").replace(" ", "");
			}
			QueryHelper query = new QueryHelper(StockDevIn.class, "sb");
			query.addCondition(StringUtils.isNotEmpty(inCheck),"inCheck=?", inCheck)
			.addCondition(StringUtils.isNotEmpty(inType),"inType=?", inType)
			.addCondition(StringUtils.isNotEmpty(startDate_in),"inDate>=?", startDate_in)
			.addCondition(StringUtils.isNotEmpty(endDate_in),"inDate<=?", endDate_in)
			.addCondition(StringUtils.isNotEmpty(startDate_check),"chkDate>=?", startDate_check)
			.addCondition(StringUtils.isNotEmpty(endDate_check),"chkDate<=?", endDate_check)
			.addOrderProperty("sb.inBillcode", false);
			query.preparePageBean(devInService, pageNum, numPerPage);
		} catch (Exception e) {
			e.printStackTrace();
		}
	
		return "devInList";
	}
	
	//入库登记审核
	public void checkDevIn(){
		DwzAjaxResult dwz = new DwzAjaxResult();
		try {
		SOPCurrentUser user=(SOPCurrentUser) ActionContext.getContext().getSession().get("currentUser");
		String userName=user.getUserName();
		String account=user.getAccount();
		SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmm");// 设置日期格式
		String nowTime = df.format(new Date());// 构造成当前时间
		HttpServletRequest request=ServletActionContext.getRequest();
		String inBillcode=request.getParameter("inBillcode");
		if(StringUtils.isNotBlank(inBillcode)){
			if(!PropertyValidate.validateStrByLength(inBillcode,10)){
				throw new Exception("设备编号传入不合法");
			 }
		}
		long  l= Long.parseLong(inBillcode);
		StockDevIn checkStock=devInService.getById(l);
		String incheck=checkStock.getInCheck();
		if(incheck.equals("0")){
		checkStock.setChkDate(nowTime);
		checkStock.setChecker(userName);
		checkStock.setInCheck("1");
			devInService.update(checkStock);
			//-----------
			
			List<StockDevInDetail> devIn=	detailSevice.getBybillCode(l);
			
			for(int i=0;i<devIn.size();i++){
				StockDevInDetail sts=devIn.get(i);
			//List<StockDev> dList=devService.getByName(sts.getDevName());
				List<StockDev> dList=devService.getByDev(sts);//审核入库时查询与入库信息匹配的库存信息
			if(dList.size()==0){//如果结果为0说明库存内没有该商品信息，直接添加
				StockDev dev=new StockDev();
				dev.setDevName(sts.getDevName());
				dev.setDevUnit(sts.getDevUnit());
				dev.setDescribe(sts.getDescribe());
				dev.setDevNum(sts.getInNum());
				dev.setDevVer(sts.getDevVer());
				dev.setDevSupplierId(sts.getDevSupplierId());
				devService.save(dev);
			}
			if(dList.size()>0){//如果结果大于0，则说明库存中有信息，入库时在数量上相加保存
				StockDev sList=null;
				for(int j=0;j<dList.size();j++){
					sList=dList.get(j);
				}
				sList.setDevNum(sts.getInNum()+sList.getDevNum());
				devService.update(sList);
				
			}
			
			}
			
		}
			dwz.setMessage("审核成功!");
			dwz.setNavTabId("stock_StockDevInList");
			dwz.setStatusCode("200");
			DwzAjaxResult.josnMessage(dwz);
		} catch (Exception e) {
			e.printStackTrace();
			dwz.setMessage("审核失败！<br>错误信息：" + e.getMessage());
			dwz.setStatusCode("300");
			DwzAjaxResult.josnMessage(dwz);
		}
		
		
	}
	
	//点击查看审核详细信息
	public String checkDevInList(){
		HttpServletRequest request=ServletActionContext.getRequest();
		List<Supplier> supList=supplierService.findAll();
		String inBillcode=request.getParameter("inBillcode");
		long  l= Long.parseLong(inBillcode);
		StockDevIn stockDevIn=devInService.getById(l);
		List<StockDevInDetail> devInList=	detailSevice.getBybillCode(l);
		Map<String,String> devSclMap=new HashMap<String,String>();//存储入库记录和对应学校
		for(StockDevInDetail dev:devInList){
			HsSchoolInfo scl=hsSchoolInfoService.getById(dev.getDevBackSclId());
			if(scl!=null){
				devSclMap.put(dev.getUuid(), scl.getSclName());
			}
		}
		ActionContext.getContext().put("devInList", devInList);
		ActionContext.getContext().put("supList", supList);
		ActionContext.getContext().put("stockDevIn", stockDevIn);
		ActionContext.getContext().put("devSclMap", devSclMap);
		return "checkList";
	}
	//驳回
	public void noCheck(){
		DwzAjaxResult dwz = new DwzAjaxResult();
		HttpServletRequest request=ServletActionContext.getRequest();
		String inBillcode=request.getParameter("inBillcode");
		long  l= Long.parseLong(inBillcode);
		StockDevIn checkStock=devInService.getById(l);
		String incheck=checkStock.getInCheck();
		try {
			if(incheck.equals("0")){
				checkStock.setInCheck("2");
				devInService.update(checkStock);
				dwz.setMessage("驳回成功!");
				dwz.setNavTabId("stock_StockDevInList");
				dwz.setStatusCode("200");
				DwzAjaxResult.josnMessage(dwz);
			}else{
			dwz.setMessage("已操作完成不允许驳回！");
			dwz.setNavTabId("stock_StockDevInList");
			dwz.setStatusCode("300");
			DwzAjaxResult.josnMessage(dwz);
			}
			
		} catch (Exception e) {
			e.printStackTrace();
			dwz.setMessage("驳回失败！<br>错误信息：" + e.getMessage());
			dwz.setStatusCode("300");
			DwzAjaxResult.josnMessage(dwz);
		}
		
		
	}
	//------------------------------出库-------------------------------------//
	//出库登记驳回
	public void nocheckout(){
		DwzAjaxResult dwz = new DwzAjaxResult();
		HttpServletRequest request=ServletActionContext.getRequest();
		String outBillcode=request.getParameter("outBillcode");
		long  l= Long.parseLong(outBillcode);
		try {
			StockDevOut devOut=outService.getById(l);
			String outCheck=devOut.getOutCheck();
			if(outCheck.equals("0")){
				devOut.setOutCheck("2");
				outService.update(devOut);
				dwz.setMessage("驳回成功!");
				dwz.setNavTabId("stock_stockDevOutList");
				dwz.setStatusCode("200");
				DwzAjaxResult.josnMessage(dwz);	
			}else{
			dwz.setMessage("已操作完成不允许驳回！");
			dwz.setNavTabId("stock_stockDevOutList");
			dwz.setStatusCode("300");
			DwzAjaxResult.josnMessage(dwz);
			}
		} catch (Exception e) {
			e.printStackTrace();
			dwz.setMessage("驳回失败！<br>错误信息：" + e.getMessage());
			dwz.setStatusCode("300");
			DwzAjaxResult.josnMessage(dwz);
		}
		
		
	}
	
	
	public String checkDevOutList(){
		List<Supplier> supList=supplierService.findAll();
		ActionContext.getContext().put("supList", supList);
		HttpServletRequest request=ServletActionContext.getRequest();
		String outBillcode=request.getParameter("outBillcode");
		long  l= Long.parseLong(outBillcode);
		List<StockDevOutDetail> od=outDetailService.getBybillCode(l);
		StockDevOut stockDevOut=outService.getById(l);
		Map<String,String> devSclMap=new HashMap<String,String>();//存储出库库记录和对应学校
		for(StockDevOutDetail dev:od){
			HsSchoolInfo scl=hsSchoolInfoService.getById(dev.getDevSclId());
			if(scl!=null){
				devSclMap.put(dev.getUuid(), scl.getSclName());
			}
		}
		ActionContext.getContext().put("devOutList", od);
		ActionContext.getContext().put("devSclMap", devSclMap);
		ActionContext.getContext().put("stockDevOut", stockDevOut);
		ActionContext.getContext().put("outBillcode", outBillcode);
		return "outShow";
	}
	
	//导出出库单明细
	public String expDevOut(){
		List<Supplier> supList=supplierService.findAll();
		ActionContext.getContext().put("supList", supList);
		HttpServletRequest request=ServletActionContext.getRequest();
		String outBillcode=request.getParameter("outBillcode");
		long  l= Long.parseLong(outBillcode);
		List<StockDevOutDetail> od=outDetailService.getBybillCode(l);
		StockDevOut stockDevOut=outService.getById(l);
		Map<String,String> devSclMap=new HashMap<String,String>();//存储出库库记录和对应学校
		Map<String,Supplier> supplierMap=new HashMap<String, Supplier>();
		for(StockDevOutDetail dev:od){
			HsSchoolInfo scl=hsSchoolInfoService.getById(dev.getDevSclId());
			if(scl!=null){
				devSclMap.put(dev.getUuid(), scl.getSclName());
			}
		}
		for(Supplier supplier:supList){
			supplierMap.put(supplier.getSupplierId(), supplier);
		}
		String[] headers = { "序号", "出库单号", "设备名称", "供应商名称", "设备版本", "设备单位", "数量","描述","去向" };
		ExportExcel<StockDevOutDetail> ex = new ExportExcel<StockDevOutDetail>();
		try {
		    fileName = "出库单" + FormatDate.dateTimeDetail() + ".xls";
		    fileName = new String(fileName.getBytes("UTF-8"), "8859_1");
		    ByteArrayOutputStream outPut = new ByteArrayOutputStream();
		    HSSFWorkbook wb = ex.exportStockOutDev(headers, od,stockDevOut,supplierMap,devSclMap);// 不带明细
		    wb.write(outPut);
		    excelFile = new ByteArrayInputStream(outPut.toByteArray());
		    outPut.flush();
		    outPut.close();
		} catch (FileNotFoundException e) {
		    e.printStackTrace();
		} catch (IOException e) {
		    e.printStackTrace();
		}
		return "excel";
	}
	
	public String stockOutDev(){
		//devList=devService.findAll();
		List<Supplier> supList=supplierService.findAll();
		Map<String,String> supMap=new HashMap<String, String>();
		for(Supplier supplier:supList){
			supMap.put(supplier.getSupplierId(), supplier.getSupplierName());
		}
		ActionContext.getContext().put("supList", supList);
		ActionContext.getContext().put("supMap", supMap);
		QueryHelper query = new QueryHelper(StockDev.class, "fg");
		query.addOrderProperty("fg.uuid", true);
		query.preparePageBean(devService, pageNum, numPerPage);
		return "devOutList";
		
	}
	
	
	//出库登记单页面
	public String stockDevOutUI(){
		
		return "stockOut";
		
	}
	//出库登记
	public void stockDevOut(){
		List<StockDevOutDetail> outDetail=new ArrayList<StockDevOutDetail>();
		for (String s : dataList) {
			StockDevOutDetail detail=new StockDevOutDetail();
			String[] str = s.split(",");
			detail.setDevUuid(str[1]);
			if(str.length>=3){
				detail.setDevSclId(schoolService.findByName(str[2]).getSclId());
			}
			detail.setOutNum(Integer.parseInt(str[0]));
			outDetail.add(detail);
		}
		DwzAjaxResult dwz = new DwzAjaxResult();
		try {
			stockService.addStockDevOut(stockDevOut, outDetail);
			dwz.setMessage("出库登记成功!");
			dwz.setNavTabId("stock_stockDevOutUI");
			dwz.setStatusCode("200");
			DwzAjaxResult.josnMessage(dwz);
			message="1";
		} catch (Exception e) {
			e.printStackTrace();
			dwz.setMessage("出库登记失败！<br>错误信息：" + e.getMessage());
			dwz.setStatusCode("300");
			DwzAjaxResult.josnMessage(dwz);
		}
		
	}
	//出库审核列表
	public String stockDevOutList(){
		try {
			String startDate_out=null;
			String endDate_out=null;
			String startDate_check=null;
			String endDate_check=null;
			if(startDate!=null){
				startDate_out=startDate.replace("-", "").replace(":", "").replace(" ", "");
			}
			if(endDate!=null){
				endDate_out=endDate.replace("-", "").replace(":", "").replace(" ", "");
			}
			if(check_startDate!=null){
				startDate_check=check_startDate.replace("-", "").replace(":", "").replace(" ", "");
			}
			if(check_endDate!=null){
				endDate_check=check_endDate.replace("-", "").replace(":", "").replace(" ", "");
			}
			QueryHelper query = new QueryHelper(StockDevOut.class, "bs");
			query.addCondition(StringUtils.isNotEmpty(outCheck),"outCheck=?", outCheck)
			.addCondition(StringUtils.isNotEmpty(outType),"outType=?", outType)
			.addCondition(StringUtils.isNotEmpty(startDate_out),"outDate>=?", startDate_out)
			.addCondition(StringUtils.isNotEmpty(endDate_out),"outDate<=?", endDate_out)
			.addCondition(StringUtils.isNotEmpty(startDate_check),"chkDate>=?", startDate_check)
			.addCondition(StringUtils.isNotEmpty(endDate_check),"chkDate<=?", endDate_check)
			.addOrderProperty("bs.outBillcode", false);
			query.preparePageBean(outService, pageNum, numPerPage);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "stockDevOutList";
	}
	
	
	public void checkDevOut(){
		DwzAjaxResult dwz = new DwzAjaxResult();
		SOPCurrentUser user=(SOPCurrentUser) ActionContext.getContext().getSession().get("currentUser");
		String userName=user.getUserName();
		SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmm");// 设置日期格式
		String nowTime = df.format(new Date());// 构造成当前时间
		HttpServletRequest request=ServletActionContext.getRequest();
		String outBillcode=request.getParameter("outBillcode");
		long  l= Long.parseLong(outBillcode);
		int k=0;
		try {
			StockDevOut devOut=outService.getById(l);
			String outCheck=devOut.getOutCheck();
			if(outCheck.equals("0")){
			devOut.setChecker(userName);
			devOut.setChkDate(nowTime);
			devOut.setOutCheck("1");
			outService.update(devOut);
			//------
			List<StockDevOutDetail> od=outDetailService.getBybillCode(l);
			StockDevOutDetail dod=null;
			for(int x=0;x<od.size();x++){
				dod=od.get(x);
			
				//List<StockDev> oList=devService.getByName(dod.getDevName());
				List<StockDev> oList=devService.getByDev(dod);
				if(oList.size()>0){
					StockDev tst=null;
					for (int y=0;y<oList.size();y++){
						tst=oList.get(y);
						if(tst.getDevNum()-dod.getOutNum()<0){
							k++;
							break;
						}
					}
				}else{//如果库存没有该物品则也应结束循环
					k++;
					break;
				}
			}
		
			if(k>0){
				devOut.setOutCheck("2");
				outService.update(devOut);
				dwz.setMessage("库存数量不足,申请驳回！");
				dwz.setNavTabId("stock_stockDevOutList");
				dwz.setStatusCode("200");
				DwzAjaxResult.josnMessage(dwz);	
				
			}else{
				
				List<StockDevOutDetail> od1=outDetailService.getBybillCode(l);
				StockDevOutDetail dod1=null;
				for(int t=0;t<od1.size();t++){
					dod1=od1.get(t);
					//List<StockDev> oList1=devService.getByName(dod1.getDevName());
					List<StockDev> oList1=devService.getByDev(dod1);
					StockDev tst1=null;
					if(oList1.size()>0){
						for (int m=0;m<oList1.size();m++){
							tst1=oList1.get(m);
						}
						tst1.setDevNum(tst1.getDevNum()-dod1.getOutNum());
						devService.update(tst1);
					}
				}
			dwz.setMessage("审核成功!");
			dwz.setNavTabId("stock_stockDevOutList");
			dwz.setStatusCode("200");
			DwzAjaxResult.josnMessage(dwz);
			}
			}else{
			dwz.setMessage("审核成功!");
			dwz.setNavTabId("stock_stockDevOutList");
			dwz.setStatusCode("200");
			DwzAjaxResult.josnMessage(dwz);
			}
		} catch (Exception e) {
			e.printStackTrace();
			dwz.setMessage("审核失败！<br>错误信息：" + e.getMessage());
			dwz.setStatusCode("300");
			DwzAjaxResult.josnMessage(dwz);
		}
		
		
	}
	
	
	public StockDevIn getStockDevin() {
		return stockDevin;
	}


	public void setStockDevin(StockDevIn stockDevin) {
		this.stockDevin = stockDevin;
	}


	public StockDeviceDic getDevDic() {
		return devDic;
	}
	public void setDevDic(StockDeviceDic devDic) {
		this.devDic = devDic;
	}


	public List<StockDeviceDic> getDicList() {
		return dicList;
	}


	public void setDicList(List<StockDeviceDic> dicList) {
		this.dicList = dicList;
	}


	public List<String> getDataList() {
		return dataList;
	}


	public void setDataList(List<String> dataList) {
		this.dataList = dataList;
	}


	public String getMessage() {
		return message;
	}


	public void setMessage(String message) {
		this.message = message;
	}


	public StockDevOut getStockDevOut() {
		return stockDevOut;
	}


	public void setStockDevOut(StockDevOut stockDevOut) {
		this.stockDevOut = stockDevOut;
	}


	public List<StockDev> getDevList() {
		return devList;
	}


	public void setDevList(List<StockDev> devList) {
		this.devList = devList;
	}


	public String getFileName() {
		return fileName;
	}


	public void setFileName(String fileName) {
		this.fileName = fileName;
	}


	public InputStream getExcelFile() {
		return excelFile;
	}


	public void setExcelFile(InputStream excelFile) {
		this.excelFile = excelFile;
	}


	public String getOutCheck() {
		return outCheck;
	}


	public void setOutCheck(String outCheck) {
		this.outCheck = outCheck;
	}


	public String getInCheck() {
		return inCheck;
	}


	public void setInCheck(String inCheck) {
		this.inCheck = inCheck;
	}


	public String getInType() {
		return inType;
	}


	public void setInType(String inType) {
		this.inType = inType;
	}


	public String getOutType() {
		return outType;
	}


	public void setOutType(String outType) {
		this.outType = outType;
	}


	public String getStartDate() {
		return startDate;
	}


	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}


	public String getEndDate() {
		return endDate;
	}


	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}


	public String getCheck_startDate() {
		return check_startDate;
	}


	public void setCheck_startDate(String check_startDate) {
		this.check_startDate = check_startDate;
	}


	public String getCheck_endDate() {
		return check_endDate;
	}


	public void setCheck_endDate(String check_endDate) {
		this.check_endDate = check_endDate;
	}
	
	
}
